﻿package net.wangit.framework.log;

import net.wangit.framework.util.SIP;
import net.wangit.jdbc.Type;

public class TAccessLog {

	public static final String TABLENAME = "ACCESSLOG";
	public static final SIP TYPE = new SIP("type", 0);
	public static final SIP USER_ID = new SIP("userid", 1);
	public static final SIP USER_NAME = new SIP("username", 2);
	public static final SIP ORGANIZATION_ID = new SIP("org", 3);
	public static final SIP DOMAIN = new SIP("domain", 4);
	public static final SIP GROUP_ID = new SIP("groupid", 5);
	public static final SIP GROUP_NAME = new SIP("groupname", 6);
	public static final SIP UNIT_ID = new SIP("unitid", 7);
	public static final SIP UNIT_NAME = new SIP("unitname", 8);
	public static final SIP ELEMENT_ID = new SIP("elementid", 9);
	public static final SIP ELEMENT_NAME = new SIP("elementname", 10);
	public static final SIP COST = new SIP("cost", 11);
	public static final SIP OK = new SIP("ok", 12);
	public static final SIP TIME = new SIP("curtime", 13);
	protected static final int COLUMN_COUNT = 14;
	protected static int TYPES[] = new int[14];
	protected static final String INSERT_SQL = getSql();

	public TAccessLog() {
	}

	private static String getSql() {
		StringBuffer sql = new StringBuffer("insert into ");
		sql.append("ACCESSLOG").append("(");
		sql.append(TYPE.name).append(",");
		TYPES[TYPE.index] = Type.INTEGER;
		sql.append(USER_ID.name).append(",");
		TYPES[USER_ID.index] = Type.VARCHAR;
		sql.append(USER_NAME.name).append(",");
		TYPES[USER_NAME.index] = Type.VARCHAR;
		sql.append(ORGANIZATION_ID.name).append(",");
		TYPES[ORGANIZATION_ID.index] = Type.VARCHAR;
		sql.append(DOMAIN.name).append(",");
		TYPES[DOMAIN.index] = Type.VARCHAR;
		sql.append(GROUP_ID.name).append(",");
		TYPES[GROUP_ID.index] = Type.VARCHAR;
		sql.append(GROUP_NAME.name).append(",");
		TYPES[GROUP_NAME.index] = Type.VARCHAR;
		sql.append(UNIT_ID.name).append(",");
		TYPES[UNIT_ID.index] = Type.VARCHAR;
		sql.append(UNIT_NAME.name).append(",");
		TYPES[UNIT_NAME.index] = Type.VARCHAR;
		sql.append(ELEMENT_ID.name).append(",");
		TYPES[ELEMENT_ID.index] = Type.VARCHAR;
		sql.append(ELEMENT_NAME.name).append(",");
		TYPES[ELEMENT_NAME.index] = Type.VARCHAR;
		sql.append(COST.name).append(",");
		TYPES[COST.index] = Type.INTEGER;
		sql.append(OK.name).append(",");
		TYPES[OK.index] = Type.INTEGER;
		sql.append(TIME.name);
		TYPES[TIME.index] = Type.TIMESTAMP;
		sql.append(") values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
		return sql.toString();
	}

}
